Optimal. Leaf size=62 \[ \frac {2 b^2 \tan ^{-1}\left (\frac {b+a \tan \left (\frac {x}{2}\right )}{\sqrt {a^2-b^2}}\right )}{a^2 \sqrt {a^2-b^2}}+\frac {b \tanh ^{-1}(\cos (x))}{a^2}-\frac {\cot (x)}{a} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.09, antiderivative size = 62, normalized size of antiderivative = 1.00, number of steps
used = 7, number of rules used = 7, integrand size = 13, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.538, Rules used = {2881, 12, 2826,
3855, 2739, 632, 210} \begin {gather*} \frac {2 b^2 \text {ArcTan}\left (\frac {a \tan \left (\frac {x}{2}\right )+b}{\sqrt {a^2-b^2}}\right )}{a^2 \sqrt {a^2-b^2}}+\frac {b \tanh ^{-1}(\cos (x))}{a^2}-\frac {\cot (x)}{a} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 12
Rule 210
Rule 632
Rule 2739
Rule 2826
Rule 2881
Rule 3855
Rubi steps
\begin {align*} \int \frac {\csc ^2(x)}{a+b \sin (x)} \, dx &=-\frac {\cot (x)}{a}-\frac {\int \frac {b \csc (x)}{a+b \sin (x)} \, dx}{a}\\ &=-\frac {\cot (x)}{a}-\frac {b \int \frac {\csc (x)}{a+b \sin (x)} \, dx}{a}\\ &=-\frac {\cot (x)}{a}-\frac {b \int \csc (x) \, dx}{a^2}+\frac {b^2 \int \frac {1}{a+b \sin (x)} \, dx}{a^2}\\ &=\frac {b \tanh ^{-1}(\cos (x))}{a^2}-\frac {\cot (x)}{a}+\frac {\left (2 b^2\right ) \text {Subst}\left (\int \frac {1}{a+2 b x+a x^2} \, dx,x,\tan \left (\frac {x}{2}\right )\right )}{a^2}\\ &=\frac {b \tanh ^{-1}(\cos (x))}{a^2}-\frac {\cot (x)}{a}-\frac {\left (4 b^2\right ) \text {Subst}\left (\int \frac {1}{-4 \left (a^2-b^2\right )-x^2} \, dx,x,2 b+2 a \tan \left (\frac {x}{2}\right )\right )}{a^2}\\ &=\frac {2 b^2 \tan ^{-1}\left (\frac {b+a \tan \left (\frac {x}{2}\right )}{\sqrt {a^2-b^2}}\right )}{a^2 \sqrt {a^2-b^2}}+\frac {b \tanh ^{-1}(\cos (x))}{a^2}-\frac {\cot (x)}{a}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A]
time = 0.18, size = 91, normalized size = 1.47 \begin {gather*} \frac {\csc \left (\frac {x}{2}\right ) \sec \left (\frac {x}{2}\right ) \left (-a \cos (x)+\frac {2 b^2 \tan ^{-1}\left (\frac {b+a \tan \left (\frac {x}{2}\right )}{\sqrt {a^2-b^2}}\right ) \sin (x)}{\sqrt {a^2-b^2}}+b \left (\log \left (\cos \left (\frac {x}{2}\right )\right )-\log \left (\sin \left (\frac {x}{2}\right )\right )\right ) \sin (x)\right )}{2 a^2} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.18, size = 77, normalized size = 1.24
method | result | size |
default | \(\frac {\tan \left (\frac {x}{2}\right )}{2 a}+\frac {2 b^{2} \arctan \left (\frac {2 a \tan \left (\frac {x}{2}\right )+2 b}{2 \sqrt {a^{2}-b^{2}}}\right )}{a^{2} \sqrt {a^{2}-b^{2}}}-\frac {1}{2 a \tan \left (\frac {x}{2}\right )}-\frac {b \ln \left (\tan \left (\frac {x}{2}\right )\right )}{a^{2}}\) | \(77\) |
risch | \(-\frac {2 i}{a \left ({\mathrm e}^{2 i x}-1\right )}+\frac {b^{2} \ln \left ({\mathrm e}^{i x}+\frac {i a \sqrt {-a^{2}+b^{2}}+a^{2}-b^{2}}{b \sqrt {-a^{2}+b^{2}}}\right )}{\sqrt {-a^{2}+b^{2}}\, a^{2}}-\frac {b^{2} \ln \left ({\mathrm e}^{i x}+\frac {i a \sqrt {-a^{2}+b^{2}}-a^{2}+b^{2}}{b \sqrt {-a^{2}+b^{2}}}\right )}{\sqrt {-a^{2}+b^{2}}\, a^{2}}-\frac {b \ln \left ({\mathrm e}^{i x}-1\right )}{a^{2}}+\frac {b \ln \left ({\mathrm e}^{i x}+1\right )}{a^{2}}\) | \(173\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: ValueError} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [B] Leaf count of result is larger than twice the leaf count of optimal. 120 vs.
\(2 (56) = 112\).
time = 0.40, size = 302, normalized size = 4.87 \begin {gather*} \left [-\frac {\sqrt {-a^{2} + b^{2}} b^{2} \log \left (\frac {{\left (2 \, a^{2} - b^{2}\right )} \cos \left (x\right )^{2} - 2 \, a b \sin \left (x\right ) - a^{2} - b^{2} + 2 \, {\left (a \cos \left (x\right ) \sin \left (x\right ) + b \cos \left (x\right )\right )} \sqrt {-a^{2} + b^{2}}}{b^{2} \cos \left (x\right )^{2} - 2 \, a b \sin \left (x\right ) - a^{2} - b^{2}}\right ) \sin \left (x\right ) - {\left (a^{2} b - b^{3}\right )} \log \left (\frac {1}{2} \, \cos \left (x\right ) + \frac {1}{2}\right ) \sin \left (x\right ) + {\left (a^{2} b - b^{3}\right )} \log \left (-\frac {1}{2} \, \cos \left (x\right ) + \frac {1}{2}\right ) \sin \left (x\right ) + 2 \, {\left (a^{3} - a b^{2}\right )} \cos \left (x\right )}{2 \, {\left (a^{4} - a^{2} b^{2}\right )} \sin \left (x\right )}, -\frac {2 \, \sqrt {a^{2} - b^{2}} b^{2} \arctan \left (-\frac {a \sin \left (x\right ) + b}{\sqrt {a^{2} - b^{2}} \cos \left (x\right )}\right ) \sin \left (x\right ) - {\left (a^{2} b - b^{3}\right )} \log \left (\frac {1}{2} \, \cos \left (x\right ) + \frac {1}{2}\right ) \sin \left (x\right ) + {\left (a^{2} b - b^{3}\right )} \log \left (-\frac {1}{2} \, \cos \left (x\right ) + \frac {1}{2}\right ) \sin \left (x\right ) + 2 \, {\left (a^{3} - a b^{2}\right )} \cos \left (x\right )}{2 \, {\left (a^{4} - a^{2} b^{2}\right )} \sin \left (x\right )}\right ] \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int \frac {\csc ^{2}{\left (x \right )}}{a + b \sin {\left (x \right )}}\, dx \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [A]
time = 0.45, size = 98, normalized size = 1.58 \begin {gather*} \frac {2 \, {\left (\pi \left \lfloor \frac {x}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (a\right ) + \arctan \left (\frac {a \tan \left (\frac {1}{2} \, x\right ) + b}{\sqrt {a^{2} - b^{2}}}\right )\right )} b^{2}}{\sqrt {a^{2} - b^{2}} a^{2}} - \frac {b \log \left ({\left | \tan \left (\frac {1}{2} \, x\right ) \right |}\right )}{a^{2}} + \frac {\tan \left (\frac {1}{2} \, x\right )}{2 \, a} + \frac {2 \, b \tan \left (\frac {1}{2} \, x\right ) - a}{2 \, a^{2} \tan \left (\frac {1}{2} \, x\right )} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 7.01, size = 179, normalized size = 2.89 \begin {gather*} \frac {b^3\,\ln \left (\mathrm {tan}\left (\frac {x}{2}\right )\right )-a^2\,b\,\ln \left (\mathrm {tan}\left (\frac {x}{2}\right )\right )+b^2\,\mathrm {atan}\left (\frac {-a^2\,\mathrm {tan}\left (\frac {x}{2}\right )\,\sqrt {b^2-a^2}\,1{}\mathrm {i}+b^2\,\mathrm {tan}\left (\frac {x}{2}\right )\,\sqrt {b^2-a^2}\,4{}\mathrm {i}+a\,b\,\sqrt {b^2-a^2}\,2{}\mathrm {i}}{-a^3-3\,\mathrm {tan}\left (\frac {x}{2}\right )\,a^2\,b+2\,a\,b^2+4\,\mathrm {tan}\left (\frac {x}{2}\right )\,b^3}\right )\,\sqrt {b^2-a^2}\,2{}\mathrm {i}}{a^4-a^2\,b^2}+\frac {a\,b^2-a^3}{a^4\,\mathrm {tan}\left (x\right )-a^2\,b^2\,\mathrm {tan}\left (x\right )} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________